package com.hgw.Demo05_FacadePattern.examplesAbstractAppearance;

/**
 * Data time:2021/12/15 11:52
 * StudentID:2019112118
 * Author:hgw
 * Description: 加密外观类，充当外观类
 */
public class EncryptFacade extends AbstractEncryptFacade{

    // 维持对子系统对象的引用
    private FileReader reader;
    private CipherMachine cipher;
    private FileWriter writer;

    public EncryptFacade() {
        reader = new FileReader();
        cipher = new CipherMachine();
        writer = new FileWriter();
    }

    // 调用子系统对象的业务方法
    public void fileEncrypt(String fileNameSrc, String fileNameDes) {
        String plainStr = reader.read(fileNameSrc);
        String encryptStr = cipher.encrypt(plainStr);
        writer.write(encryptStr, fileNameDes);
    }
}
